package com.example.springbootdemo.util;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

public class ResultSetUtil {

    public static Map<String, Object> getNextRow(ResultSet resultSet) throws SQLException {
        if (resultSet == null || !resultSet.next()) {
            return null;
        }
        Map<String, Object> outputMap = new HashMap<>();
        ResultSetMetaData metaData = resultSet.getMetaData();
        int columnCount = metaData.getColumnCount();
        for (int i = 1; i <= columnCount; i++) {
            outputMap.put(metaData.getColumnName(i), resultSet.getObject(i));
        }
        return outputMap;
    }



}
